import type { RowType } from '#/views/onlineDesign/onlineTable/onlineTable.data';

import { requestClient } from '#/api/request';

export namespace OnlineTableTableApi {
  export type RowTypeFetchParams = RowType;
  export interface IdFetchParams {
    id: string;
  }
  export interface ListFetchParams {
    [key: string]: any;
  }
  export interface PageListFetchParams {
    [key: string]: any;
    pageNo: number;
    pageSize: number;
  }
}

/**
 * 分页列表查询
 */
export async function onlineTableQueryPageListApi(
  params: OnlineTableTableApi.PageListFetchParams,
) {
  return requestClient.get('/online/table/queryPageList', { params });
}

/**
 * 列表查询
 */
export async function onlineTableQueryListApi(
  params: OnlineTableTableApi.ListFetchParams,
) {
  return requestClient.get('/online/table/queryList', { params });
}

/**
 * 通过ID查询
 * @param params
 */
export async function onlineTableQueryByIdApi(
  params: OnlineTableTableApi.IdFetchParams,
) {
  return requestClient.get('/online/table/queryById', { params });
}

/**
 * 新增
 */
export async function onlineTableAddApi(
  params: OnlineTableTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/online/table/add', params);
}

/**
 * 编辑
 */
export async function onlineTableEditApi(
  params: OnlineTableTableApi.RowTypeFetchParams,
) {
  return requestClient.post('/online/table/edit', params);
}

/**
 * 删除
 * @param id 主键
 */
export async function onlineTableDelApi(id) {
  return requestClient.delete<boolean>(`/online/table/delete/${id}`);
}

/**
 * 批量删除删除
 * @param ids 主键
 */
export async function onlineTableDeleteBatchApi(ids) {
  return requestClient.delete<boolean>(`/online/table/deleteBatchByIds/${ids}`);
}
